module.exports = function ($scope, $resource, $modalInstance, FileUploader, item, toaster) {

    $scope.obj = angular.copy(item);

    $scope.ok = function () {
        if (!$scope.obj.change_num) {
            toaster.error({ title: '', body: '请填写有效数量' });
            return false;
        }
        if ($scope.obj.subsidy_num + $scope.obj.change_num < 0) {
            toaster.error({ title: '', body: '修改后余量不可小于0' });
            return false;
        }
        $resource('/api/as/puc/subsidy/updateSubsidyTotalAndOver', {}, {}).save($scope.obj, function (res) {
            if (res.errcode === 0) {
                toaster.success({ title: '', body: '修改补贴信息成功' });
                $modalInstance.close();
            } else {
                toaster.error({ title: '', body: res.errmsg });
            }
        });
    }
    $scope.close = function () {
        $modalInstance.close();
    }

};